#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSettings>
#include <QString>
#include "serialthread.h"
#include <QtSerialPort/qserialport.h>

namespace Ui {
    class MainWindow;
}


class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
//test slot
private slots:
	void fillTestData();
	void testFindSgnPck();
private slots:
	void refreshPortList();
	void openPort();
	void closePort();
	void readData();
private:
	void showError(const QString&);
	void checkBtn();
	int findSgnPck(const QByteArray &,const QByteArray &);
	void parseAnswer(const QByteArray &);
	enum PacketState {
		WaitBegin = 0x1,
		WaitEnd = 0x2
	} mPacketState;
	
    Ui::MainWindow *ui;
	QSettings mSettings;
	QSerialPort *mPort;

	int mSgnCount;
	QByteArray mBodyPckBuffer;
};



#endif // MAINWINDOW_H